<h:form id="formPrograma" 
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"
        xmlns:f="http://java.sun.com/jsf/core">

    <script language="JavaScript" src = "scripts/script.js"/>

    <h:panelGrid style="width: 100%" columns="2">

        <h:panelGroup>

            <h:outputText value="Código" /><br/>
            <p:inputText value="#{programaBean.programa.codigo}" 
                         styleClass="up"
                         style="width: 74px"
                         required="true"
                         maxlength="4"
                         requiredMessage="Campo código requerido"/><br/>

        </h:panelGroup>

        <h:panelGroup>

            <h:outputText value="Descrição" /><br/>
            <p:inputText value="#{programaBean.programa.descricao}" 
                         styleClass="up"
                         style="width: 294px"
                         required="true"
                         requiredMessage="Campo descrição requerido"/><br/>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%">

        <h:panelGroup>

            <h:outputText value="Público alvo" /><br/>
            <p:inputText value="#{programaBean.programa.publicoAlvo}" 
                         styleClass="up"
                         style="width: 97%"
                         required="true"
                         requiredMessage="Campo público alvo requerido"/><br/>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%">

        <h:panelGroup>

            <h:outputText value="Objetivo" /><br/>
            <p:inputTextarea value="#{programaBean.programa.objetivo}" 
                             styleClass="up"
                             required="true"
                             requiredMessage="Campo objetivo requerido"
                             autoResize="false"
                             style="width: 97%"
                             /><br/>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%">

        <h:panelGroup>

            <h:outputText value="Justificativa" /><br/>
            <p:inputTextarea value="#{programaBean.programa.justificativa}" 
                             styleClass="up"
                             required="true"
                             requiredMessage="Campo justificativa requerido"
                             autoResize="false"
                             style="width: 97%" /><br/>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%">

        <h:panelGroup>

            <h:outputText value="Indicador" /><br/>
            <p:selectOneMenu value="#{programaBean.programa.indicador}" 
                             style="width: 100%"
                             required="true" 
                             requiredMessage="O campo indicador é requerido" >

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{programaBean.indicadores}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%">

        <h:panelGroup>

            <h:outputText value="Função" /><br/>
            <p:selectOneMenu value="#{programaBean.programa.funcao}" 
                             style="width: 100%"
                             required="true" 
                             requiredMessage="O campo função é requerido" >

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{programaBean.funcoes}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid columns="3"
                 style="width: 100%" >

        <h:panelGroup>

            <h:outputText value="Prazo" /><br/>
            <p:inputText value="#{programaBean.programa.prazo}" 
                         style="width: 40px"/>

        </h:panelGroup>

        <h:panelGroup>

            <h:outputText value="Tipo de Prazo" /><br/>
            <p:selectOneMenu value="#{programaBean.programa.tipoPrazo}" 
                             style="width: 100%" 
                             required="true" 
                             requiredMessage="O campo tipo de prazo é requerido" >

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{programaBean.tiposDePrazo}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

        <h:panelGroup>

            <h:outputText value="Horizonte Temporal" /><br/>
            <p:selectOneMenu value="#{programaBean.programa.horizonteTemporal}" 
                             style="width: 100%" 
                             required="true" 
                             requiredMessage="O campo horizonte temporal é requerido" >

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{programaBean.horizontesTemporais}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid style="width: 100%" columns="2"> 



        <h:panelGroup>

            <h:outputText value="Data Início" /><br/>
            <p:calendar value="#{programaBean.programa.dataInicio}" 
                        maxlength="10"
                        showOn="button" 
                        pattern="dd/MM/yyyy"
                        onkeypress="mascara(this, data)"
                        required="true" 
                        requiredMessage="O campo data íncicio é requerido"/>

        </h:panelGroup>

        <h:panelGroup>

            <h:outputText value="Data Final" /><br/>
            <p:calendar value="#{programaBean.programa.dataFinal}" 
                        maxlength="10"
                        showOn="button" 
                        pattern="dd/MM/yyyy"
                        onkeypress="mascara(this, data)"
                        required="true" 
                        requiredMessage="O campo data final é requerido"/>

        </h:panelGroup>

    </h:panelGrid>

    <h:panelGrid columns="3"
                 style="width: 100%" >

        <h:panelGroup>

            <h:outputText value="Unidade Orçamentária" /><br/>
            <p:selectOneMenu value="#{programaBean.programa.unidadeOrcamentaria}" 
                             required="true" 
                             style="width: 150px"
                             requiredMessage="O campo unidade orçamentária é requerido" >

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{programaBean.unidadesOrcamentarias}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

        <h:panelGroup>

            <h:outputText value="Natureza" /><br/>
            <p:selectOneMenu value="#{programaBean.programa.naturezaDoPrograma}" 
                             required="true" 
                             style="width: 150px"
                             requiredMessage="O campo natureza é requerido" >

                <f:selectItem itemLabel="Selecione" />
                <f:selectItems value="#{programaBean.naturezas}" />
                <f:converter converterId="simpleEntityConverter" />

            </p:selectOneMenu>

        </h:panelGroup>

        <h:panelGroup >

            <h:outputLabel value="Prioritário"/><br/>
            <p:selectOneMenu value="#{programaBean.programa.prioritario}" 
                             style="width: 80px"
                             required="true" 
                             requiredMessage="O campo prioritário é requerido">

                <f:selectItem itemLabel="Selecione" />
                <f:selectItem itemLabel="Sim" itemValue="Sim"/>
                <f:selectItem itemLabel="Não" itemValue="Não" />

            </p:selectOneMenu>

        </h:panelGroup>


    </h:panelGrid>

    <hr/>

    <p:commandButton id="btnGravar" value="Gravar" 
                     actionListener="#{programaBean.adicionarEditarFim}"
                     update="formPrograma" />

    <p:commandButton value="Cancelar" 
                     actionListener="#{programaBean.cancelar}"
                     immediate="true"/>

</h:form>


